home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
btr_oop.exe
/
BTRV_IO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-06-03
|
16KB
|
336 lines
UNIT BTRV_IO;
INTERFACE
USES DOS,GLOBALS,BTRV,OBJECTS;
Var
{global variables}
Status : Integer;
{ ---------------------Usable User Interface--------------------------------}
{ This is the first decendent of the TBtrieve object with an attempt to make }
{ the calls to the Btrv blackbox more user friendly. This attempt fails }
{ badly for certain calls especially the extended ones. Anyway the idea }
{ is to use decendents of this object with record structures added so }
{ you end up with database files/database views that know how to work on }
{ themselves.}
Type
{ This is the varient record for the Key Buffer part of the Btrv call. }
KeyBuffRecord = Record
Case Integer of
1: (IndxString : String);
2: (length : byte;
StrAry : Array[1..255] of Char);
end;
Type
PBT_IO = ^TBT_IO;
TBT_IO = object(TBtrieve)
btDataRec : Pointer;
btDataRecLen : Integer;
btKeyBuff : KeyBuffRecord;
btKey : Integer;
Constructor Init;
Destructor Done; Virtual;
Procedure SetKeyIndx(KeyNum: Integer); { use to set the index path }
Function OpenFile (FileName: TypStr25; OpenMode: Integer): Integer; {0}
Function CloseFile : Integer; {1}
Function InsertRecord : Integer; {2}
Function UpdateRecord : Integer; {3}
Function DeleteRecord: Integer; {4}
Function GetEq(ValueStr: String): Integer; {5}
Function GetNext : Integer; {6}
Function GetPrevious : Integer; {7}
Function GetGr(ValueStr: String): Integer; {8}
Function GetGrOrEq(ValueStr: String) : Integer; {9}
Function GetLs(ValueStr: String) : Integer; {10}
Function GetLsOrEq(ValueStr: String): Integer; {11}
Function GetFirst : Integer; {12}
Function GetLast : Integer; {13}
Function BeginTran: Integer; {19}
Function EndTran: Integer; {20}
Function AbortTran: Integer; {21}
Function GetPosition(Var Pozition: LongInt): Integer; {22}
Function GetDirect(Pozition: LongInt): Integer; {23}
Function StepNext : Integer; {24}
Function StopBt: Integer; {25}
Function StepFirst : Integer; {33}
Function StepLast : Integer; {34}
Function StepPrevious : Integer; {35}
end;
IMPLEMENTATION
{---------------------- TBT_IO Ancestor Object -------------------------------}
Constructor TBT_IO.Init;
begin
TBtrieve.Init;
end;
Destructor TBT_IO.Done;
begin
TBtrieve.Done;
end;
{-------------------------- Set Key Index -----------------------------------}
Procedure TBT_IO.SetKeyIndx(KeyNum: Integer); { use to set the index path }
begin
btKey := KeyNum;
end; {----------------- Set Key Index ---------------------------------------}
{-------------------- Btrieve Open (0) --------------------------------------}
Function TBT_IO.OpenFile(FileName: TypStr25; OpenMode: Integer): Integer; {0}
{ Opens a Btrieve file and returns the status code. Note this assumes no }
{ owner of the file. }
var
OwnerLen : integer;
Owner : string[10];
begin
btKeyBuff.IndxString := FileName + #0;
Owner := #0;
OwnerLen := 0;
OpenFile := Btrv(0, { 0 = Btrieve Open }
Owner[1],
OwnerLen,
btKeyBuff.StrAry,
OpenMode);
end; { ------------------- Btrieve Open -------------------------------------}
Function TBT_IO.CloseFile : Integer; {1}
Begin
CloseFile := Btrv(1, { 1 = Btrieve Close }
btDataRec^,
btDataRecLen,
btKeyBuff.IndxString[1],
0);
End;{ ----------------------Btrieve Close -----------------------------------}
{------------------------- Btrieve Insert (2) -------------------------------}
Function TBT_IO.InsertRecord : Integer; {2}
begin
InsertRecord := Btrv(2, { 2 = Btrieve Insert }
btDataRec^,
btDataRecLen,
btKeyBuff,
btKey);
end; {-------------------- Btrieve Insert -----------------------------------}
{------------------------- Btrieve Update (3) -------------------------------}
Function TBT_IO.UpdateRecord : Integer; {3}
begin
UpdateRecord := Btrv(3, { 3 = Btrieve Update }
btDataRec^,
btDataRecLen,
btKeyBuff,
btKey);
end; {-------------------- Btrieve Update -----------------------------------}
{------------------------- Btrieve Delete (4) -------------------------------}
Function TBT_IO.DeleteRecord:Integer; {4}
{ Note that the Key number is not passed in as a parameter. This is bacause }
{ if you are following Btrieves rules correctly the delete came right after }
{ a get so the btKey would already bee correctly set. }
begin
DeleteRecord := Btrv(4, { 4 = Btrieve Delete }
btDataRec^,
btDataRecLen,
btKeyBuff,
btKey);
end; {-------------------- Btrieve Delete -----------------------------------}
{----------------------- Btrieve Get Equal (5) ------------------------------}
Function TBT_IO.GetEq(ValueStr: String): Integer; {5}
begin
btKeyBuff.IndxString := ValueStr + Spaces;
GetEq := Btrv(5, { 5 = Btrieve Get Equal }
btDataRec^,
btDataRecLen,
btKeyBuff.IndxString,
btKey);
end; {----------------- Btrieve Get Equal -----------------------------------}
{----------------------- Btrieve Get Next (6) -------------------------------}
Function TBT_IO.GetNext : Integer; {6}
{ Notice that get next has no KeyNum parameter. The assumption is that some }
{ key path has already been set.}
begin
GetNext := Btrv(6, { 6 = Btrieve Get Next }
btDataRec^,
btDataRecLen,
btKeyBuff,
btKey);
end; {----------------- Btrieve Get Next ------------------------------------}
{--------------------- Btrieve Get Previous (7) -----------------------------}
Function TBT_IO.GetPrevious : Integer; {7}
{ Notice that this has no KeyNum parameter. The assumption is that some key }
{ path has already been set.}
begin
GetPrevious := Btrv(7, { 7 = Btrieve Get Previous }
btDataRec^,
btDataRecLen,
btKeyBuff,
btKey);
end; {----------------- Btrieve Get Previous --------------------------------}
{----------------------- Btrieve Get Greater (8) ----------------------------}
Function TBT_IO.GetGr(ValueStr: String): Integer; {8}
begin
btKeyBuff.IndxString := ValueStr + Spaces;
GetGr := Btrv(8, { 8 = Btrieve Get Greater }
btDataRec^,